use actix_web::HttpResponse;
use serde_json::json;

pub fn generate_ok<T: serde::Serialize>(result: T) -> HttpResponse {
    HttpResponse::Ok().json(json!({ "result": result, "error": None::<T> }))
}

pub fn generate_err(error_message: &str) -> HttpResponse {
    HttpResponse::InternalServerError()
        .json(json!({ "result": null, "error": error_message.to_string() }))
}
